<?php
include('db.php');
include('utils.php');
include('functions.php');
// connect
$host = 'localhost';
$user = 'root';
$password = '';
$database = 'baotudau_scraper';

$config = array(
  'host' => $host, 'user' => $user, 'password' => $password, 'database' => $database);
$DB = Database_MySQL::getInstance($config);
$utils = new Utils($DB);

$cat = $utils->getSubCategory(160);
$product = $utils->getProduct(138);
require 'lib/facebook.php';

// Create our Application instance (replace this with your appId and secret).
$facebook = new Facebook(array(
  'appId'  => '440380072692745',
  'secret' => 'cedec037789149d651e619220ad1476c',
));
// Get User ID

$token = $facebook->getAccessToken();
$url = 'http://www.facebook.com/marknoland139';

$id =  substr(strrchr($url,'/'),1); 

$json = file_get_contents('http://graph.facebook.com/'.$id);

$json = json_decode($json);

$id = $json->id;

$msg = 'Black Friday 2012 deals';
try {
	$facebook->api('/' . $id . '/feed', 'post' , array(
		'access_token' => $token,
		'message' => $msg,
		'link' => 'http://kinectdancegames.net'
	));
} catch(Exception $e) {
	echo $e->getMessage();
}

//include('tem1.php');
// Get sub category

?>